home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / sscanf / test2.c < prev   
Encoding:
C/C++ Source or Header  |  1992-12-10  |  484 b   |  24 lines  |  [TEXT/ALFA]

  1. /*  test2.c
  2. **
  3. ** Tests the sscanf implementation so that if an
  4. ** item is not scanned, it's variable is not changed.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. int mysscanf(const char *s, const char *f, ...);
  10.  
  11. main()
  12. {
  13.     char *s="";
  14.     char *f="";
  15.     float f1=-99;
  16.     int i1=-99, i2=-99;
  17.     char s1[40]={"Brent"};
  18.     int c1,c2;
  19.     
  20.     c1 = mysscanf(s, f, &i1, &i2);
  21.     c2 =   sscanf(s, f, &i1, &i2);
  22. printf("  mine: %d >%s< >%s,%d,%d<\n", c1, s, s1, i1, i2);
  23. printf("theirs: %d >%s< >%s,%d,%d<\n", c2, s, s1, i1, i2);
  24. }